<?php
/**
 * Created by PhpStorm.
 * User: sunzexin
 * Date: 2018/1/5
 * Time: 14:19
 */

namespace App\Http\Controllers\MiniProgram;


use App\Http\Logics\MiniProgram\MenuLogic;
use App\Http\Traits\MenuTrait;
use App\Http\Controllers\BaseController;
class MenuController extends BaseController
{
    use MenuTrait;
    public function getMenuList()
    {
        $loginSession = $this->loginSession;
        $data = [
            'loginSession' => $loginSession
        ];
        $response = MenuLogic::getMenuList($data);
        if ($response->code){
            return $this->response($response->code, $response->message);
        }
        return $this->response($response->code, $response->message, $response->data);
    }

    /**
     * @SWG\Get(
     *     path="/menu/getByMenuId",
     *     tags={"Menu"},
     *     description="通过菜单ID获取菜单",
     *     operationId="getMenuByMenuId",
     *     produces={"application/json", "application/xml", "text/xml", "text/html"},
     *     @SWG\Parameter(
     *         name="loginSession",
     *         in="query",
     *         description="验证秘钥",
     *         required=true,
     *         type="string"
     *     ),
     *     @SWG\Parameter(
     *         name="menu_id_str",
     *         in="query",
     *         description="菜单ID字符串",
     *         required=true,
     *         type="string"
     *     ),
     *     @SWG\Response(
     *         response=200,
     *         description="pet response"
     *     )
     * )
     */
    public function getMenuByMenuId()
    {
        $menu_id_str = $this->menu_id_str;
        $data = [
            'menu_id_str' => $menu_id_str
        ];
        $response = MenuLogic::getMenuByMenuId($data);
        if ($response->code){
            return $this->response($response->code, $response->message);
        }
        return $this->response($response->code, $response->message, $response->data);
    }

    /**
     * @SWG\Get(
     *     path="/menu/getMiniProgram",
     *     tags={"Menu"},
     *     description="获取用户菜单",
     *     operationId="getUserMiniProgramMenu",
     *     produces={"application/json", "application/xml", "text/xml", "text/html"},
     *     @SWG\Parameter(
     *         name="loginSession",
     *         in="query",
     *         description="验证秘钥，并且通过loginSession获取合作者信息",
     *         required=false,
     *         type="string",
     *         @SWG\Items(type="string"),
     *         collectionFormat="csv"
     *     ),
     *     @SWG\Response(
     *         response=200,
     *         description="pet response"
     *     )
     * )
     */
    public function getUserMiniProgramMenu()
    {
        $loginSession = $this->loginSession;
        $data = [
            'loginSession' => $loginSession
        ];
        $response = MenuLogic::getUserMiniProgramMenu($data);
        if ($response->code){
            return $this->response($response->code, $response->message);
        }
        return $this->response($response->code, $response->message, $response->data);
    }
}